package com.beone.admin.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.beone.admin.entity.ImportDetail;
import com.beone.admin.entity.TaskTemplateDetail;
import com.beone.admin.mapper.ImportDetailMapper;
import com.beone.admin.service.ImportDetailService;
import com.base.SuperServiceImpl;
import org.springframework.stereotype.Service;
import com.beone.admin.utils.PaginationGatagridTable;
import com.beone.admin.utils.ServiceUtils;

import java.util.Date;
import java.util.List;

/**
 * @Title 导入记录明细 服务实现类
 * @Author 秦波
 * @Version 1.0 on 2019-06-10
 * @Copyright 贝旺科权
 */
@Service
public class ImportDetailServiceImpl extends SuperServiceImpl<ImportDetailMapper, ImportDetail> implements ImportDetailService {

    /**
    * 分页显示导入记录明细列表
    * @param entity
    * @param currPage  当前页码
    * @param pageSize  每页显示记录数
    * @return
    */
    @Override
    public PaginationGatagridTable getImportDetailPagination(ImportDetail entity, int currPage, int pageSize){
        EntityWrapper<ImportDetail> ew = new EntityWrapper<ImportDetail>();
        Page<ImportDetail> page = new Page<ImportDetail>(currPage,pageSize);
        List<ImportDetail> rows = baseMapper.selectPage(page, ew);
        return ServiceUtils.createGatagridTableJson(page,rows);
    }

    @Override
    public List<ImportDetail> getImportDetailList(Integer deptId, Date startDate, Date endDate) {
        EntityWrapper<ImportDetail> ew = new EntityWrapper<>();
        ew.eq("dept_id", deptId);
        ew.ge("detail_date", startDate);
        ew.le("detail_date", endDate);
        return baseMapper.selectList(ew);
    }
}
